<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
    <script>
        function A(name, age, sex) {
            this.name = name;
            this.age = age;
            this.sex = sex;
        }
        A.prototype.eat = function() {
            console.log(this.name + '今年' + this.age + '岁了，他是一个' + this.sex + '孩');
        }

        // 构造函数继承
        // function B(name, age, sex, like) {
        //     A.apply(this, arguments);
                // this.like = like;
        // }

        // 原型继承
        // function B(name, age, sex, like) {
        //     this.like = like;
        // }
        // B.prototype = new A('小明', 20, '女');

        // 组合式继承
        function B(name, age, sex, like) {
            A.apply(this, arguments);
            this.like = like;
        }
        // B.prototype = new A('小明', 20, '女');
        B.prototype = new A();


        var aa = new B('小明', 18, '男', '篮球');
        console.log(aa);
      

    </script>
</body>
</html>